]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
screenshot-ui: Extract _saveScreenshot()
authorIvan Molodetskikh <yalterz@gmail.com>
Tue, 17 Aug 2021 07:54:05 +0000 (10:54 +0300)
committerMarge Bot <marge-bot@gnome.org>
Thu, 27 Jan 2022 22:25:42 +0000 (22:25 +0000)
For simpler handling of screenshot/screencast.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1954>

js/ui/screenshot.js

index 74660bba8c4a05521bfdf0ab536b65c250fb27c9..a02ce89427926380e4ba67fb24c826947190c2cb 100644 (file)
@@ -1523,16 +1523,21 @@ class ScreenshotUI extends St.Widget {
     }
 
     _onCaptureButtonClicked() {
+        this._saveScreenshot();
+
+        // TODO: screencasting.
+
+        this.close();
+    }
+
+    _saveScreenshot() {
         global.display.get_sound_player().play_from_theme(
             'screen-capture', _('Screenshot taken'), null);
 
         if (this._selectionButton.checked || this._screenButton.checked) {
             const content = this._stageScreenshot.get_content();
-            if (!content) {
-                // Failed to capture the screenshot for some reason.
-                this.close();
-                return;
-            }
+            if (!content)
+                return; // Failed to capture the screenshot for some reason.
 
             const texture = content.get_texture();
             const stream = Gio.MemoryOutputStream.new_resizable();
@@ -1572,10 +1577,8 @@ class ScreenshotUI extends St.Widget {
                 return;
 
             const content = window.windowContent;
-            if (!content) {
-                this.close();
+            if (!content)
                 return;
-            }
 
             const texture = content.get_texture();
             const stream = Gio.MemoryOutputStream.new_resizable();
@@ -1606,8 +1609,6 @@ class ScreenshotUI extends St.Widget {
                 logError(err, 'Error capturing screenshot');
             });
         }
-
-        this.close();
     }
 
     vfunc_key_press_event(event) {